package vo;

import java.util.Date;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Table;

import tool.DateUtils;

@Entity
@NamedQueries({ @NamedQuery(name = "Log.findAll", query = "select l from Log l"), @NamedQuery(name = "Log.findByUserIdMessage", query = "select l from Log l where l.user.id=? and l.message=?"),
		@NamedQuery(name = "Log.findByUserIdType", query = "select l from Log l where l.user.id=? and l.type=?"),
		@NamedQuery(name = "Log.findByUserId", query = "select l from Log l where l.user.id=?"), @NamedQuery(name = "Log.findTotalCount", query = "select count(*) from Log t") })
@Table(name = "log")
public class Log extends BaseEntity {

	@Column(name = "dttm")
	Date dttm;

	@Column(name = "message")
	String message;// 存阅读的id

	@Column(name = "type")
	String type;

	@JoinColumn(name = "user_id")
	@ManyToOne(fetch = FetchType.LAZY)
	private User user;

	public Date getDttm() {
		return dttm;
	}

	public String getDttmStr() {
		return DateUtils.date2Str(dttm, "-");
	}

	public void setDttm(Date dttm) {
		this.dttm = dttm;
	}

	public String getMessage() {
		return message;
	}

	public void setMessage(String message) {
		this.message = message;
	}

	public String getType() {
		return type;
	}

	public void setType(String type) {
		this.type = type;
	}

	public User getUser() {
		return user;
	}

	public void setUser(User user) {
		this.user = user;
	}

}
